package com.heima.admin.controller.v1;

import com.heima.apis.wemedia.IWemediaClient;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.dtos.WmSensitivePageReqDto;
import com.heima.model.wemedia.pojos.WmSensitive;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
public class AdSensitiveController  {

    @Autowired
    private IWemediaClient wemediaClient;

    //删除敏感词
    @DeleteMapping("/del/{id}")
    public ResponseResult delSensitive(@PathVariable Integer id){
        if(id == null){
            ResponseResult.errorResult(AppHttpCodeEnum.DATA_NOT_EXIST);
        }
        wemediaClient.delSensitive(id);
        return ResponseResult.okResult(null);
    }

    //列表查询敏感词
    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmSensitivePageReqDto dto){
        ResponseResult result = wemediaClient.findSensitiveList(dto);
        return result;
    }

    //保存敏感词
    @PostMapping("/save")
    public ResponseResult saveSensitive(@RequestBody WmSensitive wmSensitive){
        wemediaClient.saveSensitive(wmSensitive);
        return ResponseResult.okResult(null);
    }

    //修改敏感词
    @PostMapping("/update")
    public ResponseResult updateSensitive(@RequestBody WmSensitive wmSensitive){
        wemediaClient.updateSensitive(wmSensitive);
        return ResponseResult.okResult(null);
    }

}
